/**
 * Created by aa on 2016/9/8.
 */
'use strict';
var utils=require('../common/utils');
var cac=utils.cac;

var receiveWealthReport;
var receivePointItems;
var receiveWealthClass;
//财富报告
const RECEIVE_WEALTH_REPORT='RECEIVE_WEALTH_REPORT';
//透视焦点
const RECEIVE_POINT_ITEMS='RECEIVE_POINT_ITEMS';
//财富学堂
const RECEIVE_WEALTH_CLASS='RECEIVE_WEALTH_CLASS';
//最新视点
const RECEIVE_VIEWPOINTS='RECEIVE_VIEWPOINTS';

//对外暴露变量
exports.RECEIVE_WEALTH_REPORT=RECEIVE_WEALTH_REPORT;
exports.RECEIVE_POINT_ITEMS=RECEIVE_POINT_ITEMS;
exports.RECEIVE_WEALTH_CLASS=RECEIVE_WEALTH_CLASS;
exports.RECEIVE_VIEWPOINTS=RECEIVE_VIEWPOINTS;

//对外暴露方法
exports.receiveWealthReport=receiveWealthReport=cac(RECEIVE_WEALTH_REPORT,'wealthReport');
exports.receivePointItems=receivePointItems=cac(RECEIVE_POINT_ITEMS,'pointItems');
exports.receiveWealthClas=receiveWealthClass=cac(RECEIVE_WEALTH_CLASS,'wealthClass');
exports.receiveViewPoints=cac(RECEIVE_VIEWPOINTS,'viewPoints');

//财富报告换页
exports.getWealthReportByNumber=(pageNumber,pageSize)=>{
    return (dispatch, getState) => {
        reqwest({
            url: '/api/article/type/WEALTH_REPORT?channel=0&curPage='+(pageNumber-1)+'&pageSize='+pageSize,
            method: 'get',
            contentType: 'application/json'
        })
            .then(function (data) {
                dispatch(receiveWealthReport(data));
            })
            .fail(function (err, msg) {
                alert('获取数据出错');
            })
    }
};


//焦点透视换页
exports.getPointItemsByNumber=(pageNumber,pageSize)=>{
    return (dispatch, getState) => {
        reqwest({
            url: '/api/article/type/FOCUS_VIEW?channel=0&curPage='+(pageNumber-1)+'&pageSize='+pageSize,
            method: 'get',
            contentType: 'application/json'
        })
            .then(function (data) {
                dispatch(receivePointItems(data));
            })
            .fail(function (err, msg) {
                alert('获取数据出错');
            })
    }
};


//财富学堂换页
exports.getWealthClassByNumber=(pageNumber,pageSize)=>{
    return (dispatch, getState) => {
        reqwest({
            url: '/api/article/type/WEALTH_SCHOOL?channel=0&curPage='+(pageNumber-1)+'&pageSize='+pageSize,
            method: 'get',
            contentType: 'application/json'
        })
            .then(function (data) {
                dispatch(receiveWealthClass(data));
            })
            .fail(function (err, msg) {
                alert('获取数据出错');
            })
    }
};